package com.yuke.cloud.service.omc.service.impl;

import com.yuke.cloud.service.omc.dao.OdsShopCartMapper;
import com.yuke.cloud.service.omc.entity.OdsShopCart;
import com.yuke.cloud.service.omc.service.OdsShopCartService;
import com.yuke.cloud.common.core.support.BaseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;


/**
 * Created by zys on 2018/11/15.
 */
@Service
@Transactional
public class OdsShopCartServiceImpl extends BaseService<OdsShopCart> implements OdsShopCartService {
    @Resource
    private OdsShopCartMapper odsShopCartMapper;

    @Override
    public void bitchsave(List<OdsShopCart> list) {
        odsShopCartMapper.bitchsave(list);
    }

    @Override
    public List<OdsShopCart> findAllbyid(Long id) {
        List<OdsShopCart> list=odsShopCartMapper.findAllbyid(id);
        return list;
    }

    @Override
    public void batchdelete(List<OdsShopCart> list) {
        odsShopCartMapper.batchdelete(list);
    }

    @Override
    public void batchDeleteByShopAndUser(Long userId, Long shopId) {
        Example example = new Example(OdsShopCart.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("userId", userId);
        criteria.andEqualTo("shopId", shopId);
        odsShopCartMapper.deleteByExample(example);
    }
}
